import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:s_mankey/config/resource_mananger.dart';
import 'package:s_mankey/config/router_config.dart';

/// 自定义listView
class CustomListViewCell extends StatelessWidget {

  Widget leading;  //左边的icon
  String title; //标题
  String subTitle; //标题
  Widget trailing; //右边的icon
  int index; //点击索引
  String rootString; //要跳的索引
  Map arguments;

  CustomListViewCell({this.leading, this.title, this.subTitle,this.trailing,this.index, this.rootString,this.arguments});

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        GestureDetector(
          behavior:HitTestBehavior.opaque
          ,onTap: (){
          print(rootString);
          Navigator.pushNamed(context, rootString,arguments:arguments);
        }, child:  Container(
          height: 55,
          padding: EdgeInsets.fromLTRB(15, 0, 15, 0),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: [
              Offstage(offstage: leading == null, child: leading,),
              Expanded(
                flex: 1,
                child: Padding(
                  padding: const EdgeInsets.only(left: 10),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Text(title, style: TextStyle(fontSize: AppFontSize.Size14),),
                      Offstage(offstage: subTitle == '',
                        child: Text(subTitle, style: TextStyle(fontSize: AppFontSize.Size14, color: Color(0xffa1a4a6)),),),
                    ],
                  ),
                ),
              ),
              Offstage(offstage: trailing == null, child: trailing,),
            ],
          ),
        ),),
        Container(
          width: MediaQuery.of(context).size.width,
          height: 1,
          decoration: BoxDecoration(color: Color(0xfff0f0f0)),
        )
      ],
    );
  }
}